Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2EventCenter = require("EventCenter");
var def_QQ_BannerMgr = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this._banner = null;
    this.isDestroy = true;
    this.isError = false;
    this.bannerId = "";
    this.showing = "";
  }
  return babel_createClass(_ctor, [{
    key: "Create",
    value: function Create(e, t) {
      var _this67 = this;
      if (window.qq && (this.bannerId = e, null == this._banner)) {
        var _t38 = window.qq.getSystemInfoSync();
        var _n38 = 86;
        var _o79 = 350;
        console.log("创建banner");
        this._banner = window.qq.createBannerAd({
          adUnitId: e,
          style: {
            left: (_t38.windowWidth - _o79) / 2,
            top: _t38.windowHeight - _n38,
            width: _o79
          }
        });
        this._banner.onLoad(function (e) {
          console.log("banner onLoad", e);
          _this67.Show(_this67.bannerId);
        });
        this._banner.onError(function (e) {
          console.log("banner onError", e);
        });
        this._banner.onResize(function (e) {
          console.log("size", e, _t38);
          _this67._banner.style.left = (_t38.windowWidth - e.width) / 2;
          _this67._banner.style.top = _t38.windowHeight - e.height;
          console.log("onResize", _this67._banner);
        });
      }
    }
  }, {
    key: "CreateAndShow",
    value: function CreateAndShow(e, t) {
      console.log("banner CreateAndShow", this._banner);
      this.Create(e, t);
      this.Show(e, t);
    }
  }, {
    key: "refreshAD",
    value: function refreshAD(e, t) {
      this.Destroy(e);
      this.CreateAndShow(e, t);
    }
  }, {
    key: "Show",
    value: function Show(e, t) {
      var _this68 = this;
      if (null != this._banner) {
        this.showing = "";
        console.log("banner Show", this._banner);
        this._banner.show().then(function () {
          console.log("广告显示成功");
          _this68.showing = e;
          $2EventCenter.default.postEvent("bannershow");
        }).catch(function (e) {
          console.log("广告组件出现问题", e);
        });
      } else {
        window.qq && this.CreateAndShow(e, t);
      }
    }
  }, {
    key: "Hide",
    value: function Hide(e) {
      console.log("banner Hide", e);
      if (null != this._banner) {
        this._banner.hide();
        this.showing == e && (this.showing = "");
      }
    }
  }, {
    key: "tempHide",
    value: function tempHide() {
      console.log("tempHide", this.showing);
      "" != this.showing && null != this._banner && this._banner.hide();
    }
  }, {
    key: "tempShow",
    value: function tempShow() {
      console.log("tempShow", this.showing);
      "" != this.showing && this.Show(this.showing);
    }
  }, {
    key: "Destroy",
    value: function Destroy(e) {
      console.log("::banner被删除了", this._banner);
      if (null != this._banner) {
        this.showing = "";
        this._banner.hide();
        this._banner.offLoad(function (e) {
          console.log(e);
        });
        this._banner.offError(function (e) {
          console.log(e);
        });
        this._banner.offResize(function (e) {
          console.log(e);
        });
        this._banner.destroy();
      }
      this._banner = null;
    }
  }, {
    key: "reset",
    value: function reset() {}
  }, {
    key: "RealWidth",
    get() {
      return 0;
    }
  }, {
    key: "RealHeight",
    get() {
      return 0;
    }
  }], [{
    key: "Instance",
    get() {
      _ctor._instance || (_ctor._instance = new _ctor());
      return _ctor._instance;
    }
  }]);
}();
exports.default = def_QQ_BannerMgr;